package com.yodawnla.fishing;

import org.anddev.andengine.util.MathUtils;

import com.yodawnla.fishing.system.Values;
import com.yodawnla.lib.YoActivity;

public class ItemMgr
{
	public static ItemMgr getInstance()
	{
		if (instance == null)
			instance = new ItemMgr();
		return instance;
	}

	static ItemMgr instance;
	
	YoActivity mBase = YoActivity.getBaseActivity();

	ItemMgr()
	{
		
	}

	public Fish generateFish(int fishType, int minSize, int maxSize)
	{
		Fish fish = null;
		int size = MathUtils.random(minSize, maxSize);
		int reactionTime = 0;
		switch (fishType)
		{
		case 0:
			reactionTime = 50;
			fish = new Fish(fishType, size, reactionTime);
			fish.addAttractPorperty(Values.ID.Fish4, 100);
			break;
		case 1:
			reactionTime = 40;
			fish = new Fish(fishType, size, reactionTime);
			fish.addAttractPorperty(Values.ID.Fish5, 100);
			break;
		case 2:
			reactionTime = 30;
			fish = new Fish(fishType, size, reactionTime);
			fish.addAttractPorperty(Values.ID.Fish6, 100);
			break;
		case 3:
			reactionTime = 20;
			fish = new Fish(fishType, size, reactionTime);
			fish.addAttractPorperty(Values.ID.Fish7, 100);
			break;
		case 4:
			reactionTime = 20;
			fish = new Fish(fishType, size, reactionTime);
			break;
		case 5:
			reactionTime = 20;
			fish = new Fish(fishType, size, reactionTime);
			break;
		case 6:
			reactionTime = 20;
			fish = new Fish(fishType, size, reactionTime);
			break;
		case 7:
			reactionTime = 20;
			fish = new Fish(fishType, size, reactionTime);
			break;
		}
		
		fish.setItemName(mBase.getRString(R.string.fish1+fishType));
		fish.setQuantity(1);

		return fish;
	}

	public FishBait generateFishbait(int fishbaitType)
	{
		FishBait fishbait = new FishBait(fishbaitType);
		
		int type = fishbaitType - Values.FishBaitIDOffset;
		switch (type)
		{
		case 0:
			fishbait.addAttractPorperty(Values.ID.Fish7, 1);
			break;
		case 1:
			fishbait.addAttractPorperty(Values.ID.Fish0, 100);
//			fishbait.addAttractPorperty(Values.ID.Fish2, 90);
			break;
		case 2:
			fishbait.addAttractPorperty(Values.ID.Fish1, 100);
//			fishbait.addAttractPorperty(Values.ID.Fish4, 90);
			break;
		case 3:
			fishbait.addAttractPorperty(Values.ID.Fish2, 100);
//			fishbait.addAttractPorperty(Values.ID.Fish0, 90);
//			fishbait.addAttractPorperty(Values.ID.Fish4, 90);
			break;
		case 4:
			fishbait.addAttractPorperty(Values.ID.Fish3, 100);
//			fishbait.addAttractPorperty(Values.ID.Fish0, 90);
//			fishbait.addAttractPorperty(Values.ID.Fish4, 90);
			break;
		}
		
		fishbait.setItemName(mBase.getRString(R.string.bait1+type));

		return fishbait;
	}

	public FishRod generateFishRod(int fishRodType)
	{
		FishRod fishRod = null;
		switch (fishRodType)
		{
		case 0:
			fishRod = new FishRod(fishRodType, 1);
			fishRod.addFishRodProperty(Values.ID.Bait1);
			fishRod.addFishRodProperty(Values.ID.Bait2);
			break;
		case 1:
			fishRod = new FishRod(fishRodType, 2);
			fishRod.setPrice(10);
			fishRod.addFishRodProperty(Values.ID.Bait1);
			fishRod.addFishRodProperty(Values.ID.Bait3);
			fishRod.addFishRodProperty(Values.ID.Bait4);
			break;
		case 2:
			fishRod = new FishRod(fishRodType, 3);
			fishRod.setPrice(10);
			fishRod.addFishRodProperty(Values.ID.Bait1);
			fishRod.addFishRodProperty(Values.ID.Fish0);
			fishRod.addFishRodProperty(Values.ID.Fish1);
			break;
		case 3:
			fishRod = new FishRod(fishRodType, 4);
			fishRod.setPrice(10);
			fishRod.addFishRodProperty(Values.ID.Bait1);
			fishRod.addFishRodProperty(Values.ID.Fish2);
			fishRod.addFishRodProperty(Values.ID.Fish3);
			break;
		}
		
		fishRod.addFishRodProperty(Values.ID.Bait_None);
		fishRod.setName(mBase.getRString(R.string.rod1+fishRodType));

		return fishRod;
	}
}
